<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Staff extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'staff';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'gender_text',
        'contract_status_text',
    ];
    

    public function getGenderList()
    {
        return ['1' => __('Gender 1'), '2' => __('Gender 2')];
    }


    public function getGenderTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
        $list = $this->getGenderList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getContractStatusList()
    {
        return [
                '0' => __('ContractStatus 0'),
                '1' => __('ContractStatus 1'),
                '2' => __('ContractStatus 2'),
                '3' => __('ContractStatus 3'),
                '4' => __('ContractStatus 4'),
                '5' => __('ContractStatus 5'),
                '6' => __('ContractStatus 6'),
                '7' => __('ContractStatus 7'),
                '8' => __('ContractStatus 8'),
                '9' => __('ContractStatus 9'),
                '10' => __('ContractStatus 10'),
                '2' => __('ContractStatus 21'),
        ];
    }

    public function getContractStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['contract_status']) ? $data['contract_status'] : '');
        $list = $this->getContractStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


}
